import Vue from 'vue'
import Vuex from 'vuex'

Vue.use(Vuex)

let token = sessionStorage.getItem('token');
let userInfo = JSON.parse(sessionStorage.getItem('userInfo'));
export default new Vuex.Store({
  state: {
    userInfo: userInfo,
    userToken: token,
    menuLeft:'',
  },
  getters: {
    // 实时监听state值得变化（最新状态）
    getUserInfo(state) {
      return state.userInfo
    },
    getUserToken(state) {
      return state.userToken
    }
  },
  mutations: {
    mutUserToken(state, str) {
      state.userToken = str;
    },
    mutUserInfo(state, obj) {
      state.userInfo = obj;
    },
    menuLeft(state, str){
      state.menuLeft = str;
    }
  },
  actions: {
  },
  modules: {
  }
})
